﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Brick : Object_Basic
{
    public float AmplificationSpeed;
    public float Add_Speed;
    public float Fastest;
    public string LunpanTag;
    public string BallTag;
    Transform trans;
    override protected void Start()
    {
        base.Start();
        trans = FatherObject.transform;
    }
    private void FixedUpdate()
    {
        Vector3 old = trans.localScale;
        if (AmplificationSpeed < Fastest)
        {
            AmplificationSpeed += Add_Speed;
        }
        Vector3 speed = new Vector3(AmplificationSpeed, AmplificationSpeed, 0);
        trans.localScale = old + speed;
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        //Debug.Log("Detect " + collision.gameObject.tag);
        //if (collision.gameObject.name == LunpanTag)
        //{
        //    //Debug.Log("Kick Wall");
        //    Remove(FatherObject);
        //}
        if (collision.gameObject.tag == BallTag)
        {
            if (theTag == null)
            {
                SetTag();
            }
            LifeEvent.OnBrickHit();
            Remove(FatherObject);
        }
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.name == LunpanTag)
        {
            //Debug.Log("Kick Wall");
            LifeEvent.OnBrickMissed();
            Remove(FatherObject);
        }
    }
}
